﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BlinkyDevice
{
    public abstract class Report
    {
        /// <summary>Buffer for report data</summary>
        private byte[] bufferArr;
        /// <summary>Report length</summary>
        private int length;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dev">Device creating/receiving reports</param>
        public Report(HID dev)
        {
            // Doing stuff is over-rated
        }

        /// <summary>
        /// Sets the report data array
        /// </summary>
        /// <param name="byteArray">Report data array</param>
        public void setBuffer(byte[] byteArray)
        {
            bufferArr = byteArray;
            length = bufferArr.Length;
        }

        /// <summary>
        /// Accessor for the report data array
        /// </summary>
        public byte[] buffer
        {
            get
            {
                return bufferArr;
            }
        }

        /// <summary>
        /// Accessor for the report length
        /// </summary>
        public int bufferLength
        {
            get
            {
                return length;
            }
        }
    }

    /// <summary>
    /// Base class for output reports
    /// </summary>
    public abstract class OutputReport : Report
    {
        /// <summary>
        /// Constructor - setup array with correct output length received from device
        /// </summary>
        /// <param name="Dev">Creating device</param>
        public OutputReport(HID Dev)
            : base(Dev)
        {
            setBuffer(new byte[Dev.outputReportLength]);
        }
    }

    /// <summary>
    /// Base class for input reports
    /// </summary>
    public abstract class InputReport : Report
    {
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Dev">Creating device</param>
        public InputReport(HID Dev)
            : base(Dev)
        {

        }

        /// <summary>
        /// Sets the report data using an input report
        /// </summary>
        /// <param name="arrData"></param>
        public void SetData(byte[] arrData)
        {
            setBuffer(arrData);
            ProcessData();
        }

        /// <summary>
        /// Process the input report into meaningful data
        /// </summary>
        public abstract void ProcessData();
    }
}
